package com.syni.mdd.yhd.common.all.service.impl;

import com.syni.mdd.yhd.common.all.constants.Constants;
import com.syni.mdd.yhd.common.all.dao.jpa.BmsChatAnnounDao;
import com.syni.mdd.yhd.common.all.entity.groupChat.BmsChatAnnoun;
import com.syni.mdd.yhd.common.all.service.BmsCommonService;
import com.syni.mdd.yhd.common.all.service.groupChat.BmsChatAnnounService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @className
 * @description TOO
 * @Author cfx
 * @DATE 2019/4/9 12:04
 * @VERSION 1.0
 **/
@Service
public class BmsChatAnnounServiceImpl extends BaseService<BmsChatAnnoun, Integer> implements BmsChatAnnounService {


    @Autowired
    BmsChatAnnounDao bmsChatAnnounDao;


    @Override
    public BmsChatAnnounDao getBaseDao() {
        return bmsChatAnnounDao;
    }

    @Override
    public List<BmsChatAnnoun> getLatestAnnon(Integer chatId) {
        Pageable pageable = BmsCommonService.getPageable(1,1, Sort.Direction.DESC,"newTime");
        List<BmsChatAnnoun> bmsChatAnnoun = bmsChatAnnounDao.findByChatIdAndIsDelete(chatId,Constants.COMMON_FLAG_FALSE_INT,pageable);
        return bmsChatAnnoun;
    }
}
